import os

# board options
BOARD = 'amov-icf5'

# toolchains options
ARCH = 'qx-dsp'
CPU = 'c28x'
CROSS_TOOL = 'llvm-arm'
MCPU = 'qx320f049v2'
MAP_FILE = 'fmt_' + BOARD + '.map'

# build version: debug or release
BUILD = 'debug'

TOOLCHAIN_PATH = r'D:/QX-IDE/plugins/QXTOOLS_1.0.0.202510110605/qxtools/toolchain/3slot_320f/'

WORKING_DIR = os.getcwd()

# cross_tool provides the cross compiler
# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
if CROSS_TOOL == 'llvm-arm':
    PLATFORM = 'llvm-arm'
    EXEC_PATH = TOOLCHAIN_PATH + 'bin'
    #EXEC_PATH = r'D:\QX-IDE\plugins\QXTOOLS_1.0.0.202502200248\qxtools\toolchain\3slot_320f\bin'
else:
    print('================ERROR============================')
    print('Not support %s yet!' % CROSS_TOOL)
    print('=================================================')
    exit(0)

if PLATFORM == 'llvm-arm':
    # toolchains
    PREFIX = ''
    CC = PREFIX + 'clang'
    AS = PREFIX + 'as'
    AR = PREFIX + 'ar'
    CXX = ''
    LINK = PREFIX + 'ld'
    TARGET_EXT = 'out'
    SIZE = ''
    OBJDUMP = PREFIX + 'objdump'
    OBJCPY = PREFIX + 'objcopy'

    DEVICE = ' -target dsp -mcpu=' + MCPU + ' -ffunction-sections -fdata-sections '
    CFLAGS = DEVICE + ' -g -D__dsp__ -D__CORE0__ -D__ELF__'
    AFLAGS = ' -c -mcpu=' + MCPU
    LFLAGS = ' -L ' + TOOLCHAIN_PATH + 'lib' + ' -T ldscript_DSPCore0.ld -Map=build/'+ MAP_FILE + ' --no-check-sections --gc-sections '
    LLIBS  = ['fastrt_fpu32v2', 'm', 'c', 'rt', 'dspsim']

    CPATH = ''
    LPATH = ''

    if BUILD == 'debug':
        CFLAGS += ' -O0 -gdwarf-4 -mllvm -enable-O0-opts'
        AFLAGS += ' -gdwarf-4'
    else:
        CFLAGS += ' -O1 -gdwarf-4'
        AFLAGS += ' -gdwarf-4'

    CXXFLAGS = CFLAGS
    CFLAGS += ' -std=c99'
    CXXFLAGS += ' -std=c++14'

    POST_ACTION = ''
